﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace YJKRevitDimension.SymbolTextSetting
{
	public class IndexMarkCollector : CollectorBase
	{
		public List<AnnotationSymbol> IndexMarkList { get; set; }

		public IndexMarkCollector(Autodesk.Revit.DB.Document doc)
		{
			this.IndexMarkList = new List<AnnotationSymbol>();
			base.Doc = doc;
		}

		public IndexMarkCollector()
		{
		}

		private bool IndexMarkListInit()
		{
			if (this.IndexMarkList.Count > 0)
			{
				this.IndexMarkList.Clear();
			}
			FilteredElementCollector filteredElementCollector = new FilteredElementCollector(base.Doc);
			ElementClassFilter elementClassFilter = new ElementClassFilter(typeof(FamilyInstance));
			foreach (Element element in filteredElementCollector.WherePasses(elementClassFilter).OfCategory(BuiltInCategory.OST_GenericAnnotation).ToElements())
			{
				AnnotationSymbol annotationSymbol = element as AnnotationSymbol;
				if (annotationSymbol != null && annotationSymbol.AnnotationSymbolType.Family.Name.Contains("IndexMark"))
				{
					this.IndexMarkList.Add(annotationSymbol);
				}
			}
			return true;
		}

		public override bool CollectorInit()
		{
			this.IndexMarkList.Clear();
			return this.IndexMarkListInit();
		}

		private const string FamilyName = "IndexMark";
	}
}
